package com.presto.directo.mvvm.viewmodel

import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.presto.directo.entity.BankEntity
import com.presto.directo.net.getHttpMap
import com.presto.directo.net.sign
import com.presto.directo.utils.*

class BankListViewModel(application: Application) : BaseViewModel(application) {

    val bankListLiveData = MutableLiveData<List<BankEntity>>()

    fun getBankList() {
        start(onNext = {
            showProgress()
            val bankList = getApiService().queryBankList(getHttpMap().sign(31)).getResult()
            bankListLiveData.value = bankList.sortedWith { o1, o2 -> o1.bank_code.compareTo(o2.bank_code) }
        }, onComplete = {
            dismissProgress()
        })
    }

}